﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Core.Dtos
{
    public static class LocaleStringDtoExtensions
    {
        public static string Get(this IEnumerable<LocaleStringDto> list, string cultureCode, string name)
        {         
            LocaleStringDto localeString = null;
            if(list != null)
            localeString = list.Where(x => x.Name.Equals(name) && x.CultureCode == cultureCode).FirstOrDefault();
            if (localeString != null)
                return localeString.Value;
            
            return name;
        }

        public static IList<LocaleStringDto> FindByKey(this IEnumerable<LocaleStringDto> list, string name)
        {
            return list.Where(x => x.Name.Equals(name)).ToList();
        }
    }
}